<div align="left" style="padding:1px 2px 1px 2px;"><?php $session->flash(); ?></div>

<style type="text/css">
.noColor td{	
	background-color: #fff !important;	
	border-color:#FFF; 
	text-align:left;
}
</style>
<fieldset class="ui-state-active ui-corner-all">
<legend class="ui-widget-header"><?php __('Detalle Recibo de Cobranza');?></legend>
<table border="0" class="noColor">
        
        <tr>
            <td align="left"><b>Cobrado por</b></td>
            <td align="left"></td>
            <td colspan="6" align="left"><?php echo $reciboCobranza['ReciboCobranza']['nombre_vendedor'];?></td>
            <td align="right">
                <strong style="color: red;">
                    <?php echo substr($reciboCobranza['ReciboCobranza']['observaciones'],0,10);?>
                </strong>
            </td>
        </tr>
        <tr>
            <td align="left" width="100"><b>Alumno</b></td>
            <td align="left" width="80">
                <?php echo $reciboCobranza['Familia']['Alumno']['codigo'];?>
            </td>
            <td colspan="6" align="left"><?php echo $reciboCobranza['ReciboCobranza']['nombre_cliente'];?></td>
            <td align="right">
                <strong style="color: red;">
                    <?php echo $reciboCobranza['ReciboCobranza']['anulado']?'ANULADO':'';?>
                </strong>
            </td>
        </tr>
        
        <tr>
            <td align="left"><b>Recibo</b></td>
            <td align="left"><?php echo '111';?>&nbsp;</td>
            <td width="100" align="left"><strong style="color: blue;"><?php echo $reciboCobranza['ReciboCobranza']['numero_documento'];?></strong></td>
            <td width="80" align="left"><b>Fecha</b></td>
            <td width="80" align="left" colspan="5"><?php echo $time->format('d/m/Y', $reciboCobranza['ReciboCobranza']['fecha']);?>&nbsp;</td>
            
        </tr>
        <tr>
            <td align="left"><b>Importe</b></td>
            <td align="left" colspan="6"><?php echo $number->format($reciboCobranza['ReciboCobranza']['monto_recibido'], array(
                'places'=>2,
                'before'=>'',
                'thousands'=>''
            ));?></td>
           
        </tr>
        <tr>
            <td align="left"><b>Observ.</b></td>
            <td colspan="8" align="left"><?php echo $reciboCobranza['ReciboCobranza']['observaciones'];?>&nbsp;</td>
            
        </tr>
</table>
    
<table>
  <tr>
            <th></th>
            <th>Cd</th>
            <th>Numero</th>
            <th>Fecha Emision</th>
            <th colspan="2">Glosa</th>          
            <th>Cargo</th>
            <th>Abono</th>
            <th>Saldo</th>
            <th>Pago</th>
            <th></th>
        </tr>
        <?php
        $i = 0;
        $cargo = 0;
        $abono = 0;
        $saldo = 0;
        $pago = 0;
        foreach($reciboCobranza['ReciboCobranzaDetalle'] as $detalle):
            if(!isset($detalle['DocumentoReferencia']['cargo']))
                $detalle['DocumentoReferencia']['cargo'] = 0;            
            if(!isset($detalle['DocumentoReferencia']['abono']))
                $detalle['DocumentoReferencia']['abono'] = 0;            
            $cargo += $detalle['codigo_documento_ref_id']==125?$detalle['ConvenioReferencia']['suma_importe_total']: isset($detalle['DocumentoReferencia']['cargo']) ? $detalle['DocumentoReferencia']['cargo'] : 0;
            $abono += $detalle['codigo_documento_ref_id']==125?$detalle['ConvenioReferencia']['suma_importe_total']: isset($detalle['DocumentoReferencia']['abono']) ? $detalle['DocumentoReferencia']['abono'] : 0;
            
            $saldo += $detalle['codigo_documento_ref_id']==125?0:$detalle['DocumentoReferencia']['cargo']-$detalle['DocumentoReferencia']['abono'];
            $pago += $detalle['abono'];
        ?>
        <tr>
            <td align="center"><?php echo ($i++)+1;?></td>
            <td><?php echo $detalle['codigo_documento_ref_id'];?></td>
            <td><?php echo $detalle['codigo_documento_ref_id']==125?$detalle['ConvenioReferencia']['numero_documento']:isset($detalle['DocumentoReferencia']['numero_documento'])? $detalle['DocumentoReferencia']['numero_documento'] : '-' ;?></td>
            <td><?php echo isset($detalle['DocumentoReferencia']['fecha_emision']) ? $time->format('d/m/Y',$detalle['codigo_documento_ref_id']==125?$detalle['ConvenioReferencia']['fecha_emision']:$detalle['DocumentoReferencia']['fecha_emision']) : '-';?></td>
            <td colspan=2""><?php echo $detalle['codigo_documento_ref_id']==125?$detalle['ConvenioReferencia']['nombre_cliente']:isset($detalle['DocumentoReferencia']['glosa'])? $detalle['DocumentoReferencia']['glosa'] : '-' ;?></td>
            <td align="right"><?php echo $number->precision($detalle['codigo_documento_ref_id']==125?$detalle['ConvenioReferencia']['suma_importe_total']:$detalle['DocumentoReferencia']['cargo'],2);?></td>
            <td align="right"><?php echo $number->precision($detalle['codigo_documento_ref_id']==125?$detalle['ConvenioReferencia']['suma_importe_total']:$detalle['DocumentoReferencia']['abono'],2);?></td>            
            <td align="right"><?php echo $number->precision($detalle['codigo_documento_ref_id']==125?0:($detalle['DocumentoReferencia']['cargo']-$detalle['DocumentoReferencia']['abono']),2);?></td>
            <td align="right"><?php echo $number->precision($detalle['abono'],2);?></td>
            <td align="right"><strong style="color: red;"><?php echo $detalle['contado']?'Contado':'No';?></strong></td>
        </tr>
        <?php endforeach;?>
        <tr>
            <td></td>
            <td colspan="5"><b>TOTAL</b></td>
            <td align="right"><?php echo $number->precision($cargo,2);?></td>
            <td align="right"><?php echo $number->precision($abono,2);?></td>
            <td align="right"><?php echo $number->precision($saldo,2);?></td>
            <td align="right"><?php echo $number->precision($pago,2);?></td>
            <td align="right">&nbsp;</td>
        </tr>
</table>
    
 </fieldset>  
    
<div class="actions" style="padding:5px 0 5px 0;">
        <?php echo $html->link(__('Volver', true), array('action' => 'index'), array('class'=>'lnkbutton btnback')); ?>
        <?php echo $html->link(__('Nuevo', true), array('action' => 'add'), array('class'=>'lnkbutton btnnew')); ?>
        <?php echo $html->link(__('Editar', true), array('action' => 'edit', $reciboCobranza['ReciboCobranza']['id']), array('class'=>'lnkbutton btnedit')); ?>
    <?php echo $html->link(__('Imprimit', true), array('action' => 'report', $reciboCobranza['ReciboCobranza']['id']), array('class'=>'lnkbutton btnprint','target'=>'_blank')); ?>
        <?php echo $html->link(__('Eliminar', true), array('action' => 'delete', $reciboCobranza['ReciboCobranza']['id']), array('class'=>'lnkbutton btnerase'), sprintf(__('Are you sure you want to delete # %s?', true), $reciboCobranza['ReciboCobranza']['id'])); ?>
        <?php echo $html->link(__('Anular', true), array('action' => 'cancel', $reciboCobranza['ReciboCobranza']['id']), array('class'=>'lnkbutton btncancel'), sprintf(__('Are you sure you want to delete # %s?', true), $reciboCobranza['ReciboCobranza']['id'])); ?>
        <?php 
	if(!empty($vecino['prev'])){
		echo $html->link('Atrás', array('action'=>'view',$vecino['prev']['ReciboCobranza']['id']), array('class'=>'lnkbutton btnprev'));	
    }
    if(!empty($vecino['next'])){
		echo $html->link('Siguiente', array('action'=>'view',$vecino['next']['ReciboCobranza']['id']), array('class'=>'lnkbutton btnnext'));
	}
	 ?>
    </div>
</div>